<?php

class Objectship_model extends Model {

	/*function validate()
	{
		$this->db->where('login', $this->input->post('login'));
		$this->db->where('pwd', md5($this->input->post('pwd')));
		$query = $this->db->get('users');
		
		if($query->num_rows == 1)
		{
			return true;
		}	
	}
	*/
	
	function create_object()
	{
		
		//$user_id = $this->session->set_userdata($data(user_id));
		
		$new_object_insert_data = array(
			'name' => $this->input->post('name'),
			'base_price' => $this->input->post('base_price'),
			'sale_endtime' => $this->input->post('sale_endtime'),
			'description' => $this->input->post('description'),
			//'id_user' => $user_id
		);
		
		$insert = $this->db->insert('products', $new_object_insert_data);
		return $insert;
	}

	function taken_objectName($login)
	{
		$query_str = "SELECT name FROM products WHERE name = ?";
		$result = $this->db->query($query_str, $name);
		if ($result->num_rows() > 0)
		{
			//the name exists
			return true;
		}
		else
		{
			//name doesn't exists
			return false;
		}
	}

}
